package file;

import java.io.File;

public class FileDemo {
    public static void main(String[] args) {
        //"\"与"//"相同
        //File file = new File("C:/Users\\Administrator\\IdeaProjects\\JSD2411\\Demo.txt");
        File file = new File("C:\\Users\\Administrator\\IdeaProjects\\JSD2411\\Demo.txt");
        //相对路径
        //File file1 = new File("Demo.txt");
        //File file1 = new File("./Demo.txt");
        System.out.println("名字:"+file.getName());
        System.out.println("大小:"+file.length());
        System.out.println("是否存在:"+file.exists());
        System.out.println("是否目录:"+file.isDirectory());
        System.out.println("是否文件:"+file.isFile());
        System.out.println("是否能运行:"+file.canExecute());
        System.out.println("是否可读:"+file.canRead());
        System.out.println("是否可写:"+file.canWrite());

        File file1 = new File("/Demo.txt");
        System.out.println("file1名字:"+file1.getName());
        System.out.println("file1大小:"+file1.length());
        System.out.println(file1.exists());



    }
}
